﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using netpostExamples.Models;

namespace netpostExamples.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public virtual ActionResult Index()
        {
            return View();
        }

        //
        // GET: /Home/ArrayOfObjects

        public virtual JsonResult AnObject(ArrayOfObjects anObject)
        {
            if (null != anObject && 1 == anObject.Id && 3 == anObject.Dimensions.Count)
                return Json(new { message = "AnObject - everything is ok." });

            return Json(new { message = "AnObject - something went wrong!" });
        }

        //
        // GET: /Home/ArrayOfObjects

        public virtual JsonResult ArrayOfObjects(List<ArrayOfObjects> arrayOfObjects)
        {
            if (null != arrayOfObjects && 1 < arrayOfObjects.Count && 2 == arrayOfObjects[1].Id && 3 == arrayOfObjects[1].Dimensions.Count)
                return Json(new { message = "ArrayOfObjects - everything is ok." });

            return Json(new { message = "ArrayOfObjects - something went wrong!" });
        }

        //
        // GET: /Home/PersonObject

        public virtual JsonResult PersonObject(Person person)
        {
            if (null != person && "Doe" == person.LastName && null != person.ResidentialAddress
                && "Funky" == person.ResidentialAddress.Street && StreetType.Avenue == person.ResidentialAddress.TypeOfStreet
                && null != person.OtherAddresses && 0 < person.OtherAddresses.Count
                && null != person.Social && null != person.Social.Sites && 0 < person.Social.Sites.Count
                && "cookie.monster" == person.Social.Sites[0].Login)
                return Json(new { message = "PersonObject - everything is ok." });

            return Json(new { message = "PersonObject - something went wrong!" });
        }
    }
}
